
/**
 房间运营状态
 *
*/

import { State } from "framework/FSM/AState";
 
export class TaskExecuteState<T extends IStateArg<Room >> extends State<T>
{

    public getActions(arg:T):Action[]
    {
        
        const tasks = arg.entity.getTaskByType("room") ; // 房间的自动布局任务
        const towerTask = arg.entity.getTaskByType("tower")
      
        const pushAction=(tasks:ITaskDeclare["room"|"tower"][],acitons:IActionCMD[])=>
        {
            for(const task of  tasks)
            {
                const action:IActionCMD ={
                    arg:{
                        entity:arg.entity,
                        task:task as any
                    },
                    key:task.data.type,
                    priority:task.priority,
                    absort:0,
                    ttl:-1,
                }
                acitons.push(action);
            }
        }
        const actions:IActionCMD[]=[];
        if(tasks)
        {
            pushAction(tasks,actions);
        }
        if(towerTask&& towerTask[0])
        {
            pushAction([towerTask[0]],actions);
        }
        return actions
    }

}
